package com.karaoke.oksrv.controller

import com.karaoke.oksrv.domain.DataDictionary
import com.karaoke.oksrv.service.DataDictionaryService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController

/**
 * Created by allen on 2017/4/26.
 */
@RestController
@RequestMapping("/api/v1/dictionary")
class DataDictionaryController
{
    @RequestMapping(method = arrayOf(RequestMethod.GET), value = "/lang")
    fun getLanguages(): List<DataDictionary> = service.getLanguages()

    @RequestMapping(method = arrayOf(RequestMethod.GET), value = "/arts")
    fun getArts(): List<DataDictionary> = service.getArts()

    @RequestMapping(method = arrayOf(RequestMethod.GET), value = "/all")
    fun dictionary() = service.getDatas()

    @RequestMapping(method = arrayOf(RequestMethod.GET), value = "/by/{pId}")
    fun dictionaryByPid(@PathVariable pId: Int) = service.getDictByPid(pId)

    @RequestMapping(method = arrayOf(RequestMethod.GET), value = "/{id}")
    fun getOne(@PathVariable id: Int) = service.findOne(id)

    @RequestMapping(value = "/areas", method = arrayOf(RequestMethod.GET))
    fun getSingerTypes(): List<DataDictionary> = service.getSingerTypes()

    @Autowired lateinit var service: DataDictionaryService


}
